﻿#region [ License information          ]
/* ************************************************************
 *
 * Copyright (c) Bjørn Bouet Smith, 2010, 2011
 *
 * This source code is subject to terms and conditions of 
 * Microsoft Public License (Ms-PL).
 * 
 * A copy of the license can be found in the license.txt
 * file at the root of this distribution. If you can not 
 * locate the License, please send an email to bjornsmith@gmail.com
 * 
 * By using this source code in any fashion, you are 
 * agreeing to be bound by the terms of the Microsoft 
 * Public License.
 *
 * You must not remove this notice, or any other, from this
 * software.
 *
 * ************************************************************/
#endregion

using System;

namespace Smith.AMC
{
    /// <summary>
    /// Represents a cache item that is either retrieved from the cache, or
    /// an item that is ready to be stored in the cache
    /// </summary>
    public interface ICacheItem
    {
        /// <summary>
        /// Gets or sets the cas value.
        /// the CAS value is to be used if an item is retrieved from the cache, modified
        /// and then added to the cache again.
        /// </summary>
        ulong CASValue
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the cache key, by which the item is identified in the cache
        /// </summary>
        string CacheKey
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the underlying value cached
        /// </summary>
        object Value
        {
            get;
            set;
        }

        /// <summary>
        /// Gets or sets the life time of the item in the cache.
        /// This property should be set when adding items to the cache.
        /// </summary>
        TimeSpan LifeTime
        {
            get;
            set;
        }
    }

    /// <summary>
    /// Represents a typed cache item, where the value is of a certain type identified by <typeparamref name="T"/>
    /// </summary>
    /// <typeparam name="T">The type of the value cached</typeparam>
    public interface ICacheItem<T> : ICacheItem
    {
        /// <summary>
        /// Gets or sets the underlying value cached
        /// </summary>
        new T Value
        {
            get;
            set;
        }
    }
}
